package ctrdashboard

import (
	"cloud_worm/wormweb/controllers/ctrconfig"
	"cloud_worm/util/uhttp"
)

type FirstRowCtr struct {
	ctrconfig.LoginCtr
}

func (f *FirstRowCtr) MachineInfo()  {
	if f.Guest() == false {
		return
	}

	type MachineBriefInfo struct {
		All 		int
		Normal 		int
		Trouble 	int
		SoldOut		int
	}

	mData := MachineBriefInfo{
		All: 12423,
		Normal: 11000,
		Trouble: 1000,
		SoldOut: 423,
	}
	// TODO: 待实现具体是获取数据，采用redis进行缓存
	f.Data["json"] = uhttp.CreateOkResponse(mData)
	f.ServeJSON()
	return
}

func (f *FirstRowCtr) OnlineRate()  {
	if f.Guest() == false {
		return
	}

	type OnlineRateInfo struct {
		All 		int
		Normal 		int
		Online 		int
		AllRate 	float32
		NormalRate  float32
	}

	mData := OnlineRateInfo{
		All: 12423,
		Normal: 11000,
		Online: 10400,
		AllRate: 10400/12423,
		NormalRate: 10400/11000,
	}
	// TODO: 待实现具体获取数据
	f.Data["json"] = uhttp.CreateOkResponse(mData)
	f.ServeJSON()
	return
}

func (f *FirstRowCtr) TaskCnt()  {
	if f.Guest() == false {
		return
	}

	type TaskBriefInfo struct {
		All 		int
		CurrentWeek int
	}
	mData := TaskBriefInfo{
		All: 567,
		CurrentWeek: 45,
	}
	// TODO: 待实现具体获取数据

	f.Data["json"] = uhttp.CreateOkResponse(mData)
	f.ServeJSON()
	return
}

func (f *FirstRowCtr) AlertCnt()  {
	if f.Guest() == false {
		return
	}

	type AlertBriefInfo struct {
		All 		int
		CurrentWeek int
	}
	mData := AlertBriefInfo{
		All: 678,
		CurrentWeek: 89,
	}
	// TODO: 待实现具体获取数据

	f.Data["json"] = uhttp.CreateOkResponse(mData)
	f.ServeJSON()
	return
}